//
//  OrderAddressCell.m
//  Ufan
//
//  Created by yangqingluo on 15/12/8.
//  Copyright © 2015年 yangqingluo. All rights reserved.
//

#import "OrderAddressCell.h"

@interface OrderAddressCell()

@property (strong, nonatomic) UIView *bottomLineView1;
@property (strong, nonatomic) UILabel *detailAddressLabel;

@end

@implementation OrderAddressCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.textLabel.font = [UIFont systemFontOfSize:14.0];
        
        self.detailTextLabel.font = self.textLabel.font;
        self.detailTextLabel.textColor = self.textLabel.textColor;
        
        _bottomLineView1 = [[UIView alloc] init];
        _bottomLineView1.backgroundColor = UFCOLOR_GRAYLINE;
        [self.contentView addSubview:_bottomLineView1];

        _detailAddressLabel = [[UILabel alloc]init];
        _detailAddressLabel.font = [UIFont systemFontOfSize:12.0];
        _detailAddressLabel.textColor = self.textLabel.textColor;
        [self.contentView addSubview:_detailAddressLabel];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _bottomLineView1.frame = CGRectMake(15, self.height - 1, self.width - 30, 1);
    
    if ([AppPublic shareInstanceApp].addressSelected) {
        self.textLabel.text = [NSString stringWithFormat:@"收货人：%@",[AppPublic shareInstanceApp].addressSelected.deliveryName];
        self.detailTextLabel.text = starMiddle([AppPublic shareInstanceApp].addressSelected.deliveryPhone);
        
        self.detailAddressLabel.frame = CGRectMake(self.textLabel.left, self.textLabel.bottom + 5, _bottomLineView1.right - self.textLabel.left, 14);
        self.detailAddressLabel.hidden = NO;
        self.detailAddressLabel.text = [NSString stringWithFormat:@"收货地址：%@",[AppPublic shareInstanceApp].addressSelected.detailAddress];
    }
    else{
        self.textLabel.text = @"添加收货地址";
        self.detailAddressLabel.hidden = YES;
    }
    
    
    
}

+(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}

@end
